import { Component, OnInit, Input } from '@angular/core';
import { parse } from 'papaparse';
@Component({
  selector: 'table-block',
  templateUrl: './table-block.component.html',
  styleUrls: ['./table-block.component.scss']
})
export class TableBlockComponent implements OnInit {

  constructor() { }

  @Input() value!:string;
  @Input() edit:boolean = false;
  
  head:any[] = [];
  rows:any[][] = [];

  ngOnInit(): void {
    const records = parse(this.value, { skipEmptyLines: true, delimiter:"|",  });
    let datas:any[][] = records.data as any[][];
    if(datas.length > 0) {
      this.head = datas[0];
      this.rows = datas.slice(1,datas.length);
    }

  }

}
